Skip to content

.NET: Add Foundry Memory Context Provider#3522

Merged
rogerbarreto merged 19 commits intomicrosoft:mainfrom
rogerbarreto:features/foundry-memory-context-provider
Feb 20, 2026
Merged

.NET: Add Foundry Memory Context Provider#3522
rogerbarreto merged 19 commits intomicrosoft:mainfrom
rogerbarreto:features/foundry-memory-context-provider

Conversation

@rogerbarreto
Copy link
Member

@rogerbarreto rogerbarreto commented Jan 30, 2026

Closes #3673

Motivation and Context

Add Azure AI Foundry Memory Context Provider

Introduces Microsoft.Agents.AI.FoundryMemory, a new context provider package that enables agents to store
and retrieve long-term memories using Azure AI Foundry's managed memory service. The provider
automatically extracts memories from conversations and retrieves relevant memories to augment agent
context on each invocation, following the same pattern established by the Mem0 provider.

Features

  • FoundryMemoryProvider implementing AIContextProvider with automatic memory extraction and retrieval
  • Overrides ProvideAIContextAsync and StoreAIContextAsync following the updated AIContextProvider base class pattern
  • Uses ProviderSessionState<State> for automatic session state management (same pattern as Mem0Provider)
  • Scoped memory storage by configurable identifier (e.g., user ID) for multi-tenant scenarios via FoundryMemoryProviderScope
  • EnsureMemoryStoreCreatedAsync() to create memory stores with specified chat and embedding models
  • EnsureStoredMemoriesDeletedAsync() to clear memories for a scope
  • WhenUpdatesCompletedAsync() to poll pending memory updates in parallel until completion
  • Configurable options (FoundryMemoryProviderOptions) for max memories, update delay, context prompt, state key, and message filters
  • Sample application (AgentWithMemory_Step04_MemoryUsingFoundry) demonstrating end-to-end usage with session serialization
  • Unit tests for constructor validation
  • Integration tests using agent-based API (skipped by default, require live Foundry service)

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add [BREAKING] prefix to the title of the PR.

@rogerbarreto rogerbarreto self-assigned this Jan 30, 2026
@markwallace-microsoft markwallace-microsoft added documentation Improvements or additions to documentation .NET labels Jan 30, 2026
@github-actions github-actions bot changed the title .Net: Add Foundry Memory Context Provider [WIP] .NET: Add Foundry Memory Context Provider [WIP] Jan 30, 2026
@rogerbarreto rogerbarreto added the blocked external This label indicates whenever an issue or a PR cannot proceed due to an external dependency label Feb 4, 2026
@rogerbarreto rogerbarreto moved this to In Progress in Agent Framework Feb 12, 2026
@rogerbarreto rogerbarreto moved this from In Progress to In Review in Agent Framework Feb 12, 2026
@rogerbarreto rogerbarreto moved this from In Review to In Progress in Agent Framework Feb 12, 2026
@rogerbarreto rogerbarreto changed the title .NET: Add Foundry Memory Context Provider [WIP] .NET: Add Foundry Memory Context Provider Feb 18, 2026
…eation

- Remove IFoundryMemoryOperations interface (was only for test mocking)
- Remove AIProjectClientMemoryOperations wrapper class
- Provider now directly uses AIProjectClient with internal extension methods
- Extension methods return actual response models instead of extracted values
- Remove WaitForUpdateCompletionAsync from provider (sample uses delay)
- Simplify EnsureMemoryStoreCreatedAsync to return Task instead of Task<bool>
- Add memory store creation with chat_model and embedding_model
- Add UpdateMemoriesResponse with SupersededBy and Error fields
- Simplify unit tests to focus on constructor validation and serialization
- Update sample to use simple delay for memory processing wait
- Move memoryStoreName from options to required constructor parameter
- Make FoundryMemoryProviderScope require non-null/whitespace scope in constructor
- Make Scope property read-only (getter only)
- Replace ConcurrentQueue with single last update ID to fix memory leak
- Only clear pending update ID after successful completion
- Add delete success logging
- Mark FoundryMemoryProvider with [Experimental] attribute
- Update unit tests for new API signatures

Co-authored-by: Copilot <[email protected]>
@rogerbarreto rogerbarreto added this pull request to the merge queue Feb 19, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 19, 2026
@rogerbarreto rogerbarreto added this pull request to the merge queue Feb 19, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Feb 19, 2026
@rogerbarreto rogerbarreto added this pull request to the merge queue Feb 20, 2026
Merged via the queue into microsoft:main with commit 0e2fcb1 Feb 20, 2026
15 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Agent Framework Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation .NET

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

.NET: Add IContextProvider implementation for Foundry Memory

5 participants